package com.example.demo.base.permission.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.base.permission.dto.UserRoleDto;
import com.example.demo.domain.entity.PermissionFrontUrl;
import com.example.demo.dto.ResponseDto;
import com.example.demo.param.PersionParam;
import com.example.demo.param.UserRoleParam;
import com.example.demo.service.UserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * TODO
 *
 * @author mazh47622
 * @date2023/12/5
 * @modify -----------------------------------------------------------------------------------------------------
 * |修改单号|修改人员|修改日期|评审人员|修改说明
 * -----------------------------------------------------------------------------------------------------
 * |      |       |      |       |
 * -----------------------------------------------------------------------------------------------------
 */

@RequestMapping("/role")
@RestController
public class RoleController {

    @Autowired
    private UserRoleService userRoleService;
    /**
     * 角色创建，给具体公司创建角色，并且赋予权限
     * @param userRoleDto
     * @return
     */

    @PostMapping("/createUserRole")
    ResponseDto createUserRole(@RequestBody UserRoleDto userRoleDto){
        userRoleService.createUserRole(userRoleDto);
        return new ResponseDto<>().buildSucceedHasData(true);
    }

    /**
     * 角色修改
     * @param userRoleDto
     * @return
     */

    @PostMapping("/updateUserRole")
    ResponseDto updateUserRole(@RequestBody UserRoleDto userRoleDto){
        userRoleService.updateUserRole(userRoleDto);
        return new ResponseDto<>().buildSucceedHasData(true);
    }

    /**
     * 角色删除
     * @param userRoleDto
     * @return
     */

    @PostMapping("/deleteUserRole")
    ResponseDto deleteUserRole(@RequestBody UserRoleDto userRoleDto){
        userRoleService.deleteUserRole(userRoleDto);
        return new ResponseDto<>().buildSucceedHasData(true);
    }

    /**
     * 查询角色信息
     * @param userRoleParam
     * @return
     */

    @PostMapping("/queryeUserRole")
    ResponseDto queryeUserRole(@RequestBody UserRoleParam userRoleParam){
        return new ResponseDto<>().buildSucceedHasData(userRoleService.queryeUserRole(userRoleParam));
    }
}
